import { createStore, Store, useStore as useVuexStore } from 'vuex'

import login from './login/login'
import { IRootState, IStoreType } from './types'

const store = createStore<IRootState>({
  state: () => {
    return {
      name: 'bing',
      age: 18,
      entireDepartment: [],
      entireRole: [],
      entireMenu: [],
    }
  },
  mutations: {},
  actions: {},
  modules: {
    login,
  },
})

export function useStore(): Store<IStoreType> {
  return useVuexStore()
}
export function setupStore() {
  store.dispatch('login/loadLocalLogin')
}
export default store
